/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package library.impl;

import java.util.Date;

import library.Book;
import library.LibraryPackage;
import library.RentRecord;
import library.Renter;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc --> An implementation of the model object '<em><b>Rent Record</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link library.impl.RentRecordImpl#getRenter <em>Renter</em>}</li>
 * <li>{@link library.impl.RentRecordImpl#getBook <em>Book</em>}</li>
 * <li>{@link library.impl.RentRecordImpl#getRentDate <em>Rent Date</em>}</li>
 * <li>{@link library.impl.RentRecordImpl#getExpectedReturnDate <em>Expected Return Date</em>}</li>
 * <li>{@link library.impl.RentRecordImpl#getReturnDate <em>Return Date</em>}</li>
 * </ul>
 * </p>
 * 
 * @generated
 */
public class RentRecordImpl extends EObjectImpl implements RentRecord {
	/**
	 * The cached value of the '{@link #getRenter() <em>Renter</em>}'
	 * reference. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getRenter()
	 * @generated
	 * @ordered
	 */
	protected Renter renter;

	/**
	 * The cached value of the '{@link #getBook() <em>Book</em>}' reference.
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getBook()
	 * @generated
	 * @ordered
	 */
	protected Book book;

	/**
	 * The default value of the '{@link #getRentDate() <em>Rent Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getRentDate()
	 * @generated
	 * @ordered
	 */
	protected static final Date RENT_DATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getRentDate() <em>Rent Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getRentDate()
	 * @generated
	 * @ordered
	 */
	protected Date rentDate = RENT_DATE_EDEFAULT;

	/**
	 * The default value of the '{@link #getExpectedReturnDate() <em>Expected Return Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getExpectedReturnDate()
	 * @generated
	 * @ordered
	 */
	protected static final Date EXPECTED_RETURN_DATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getExpectedReturnDate() <em>Expected Return Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getExpectedReturnDate()
	 * @generated
	 * @ordered
	 */
	protected Date expectedReturnDate = EXPECTED_RETURN_DATE_EDEFAULT;

	/**
	 * The default value of the '{@link #getReturnDate() <em>Return Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getReturnDate()
	 * @generated
	 * @ordered
	 */
	protected static final Date RETURN_DATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getReturnDate() <em>Return Date</em>}'
	 * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getReturnDate()
	 * @generated
	 * @ordered
	 */
	protected Date returnDate = RETURN_DATE_EDEFAULT;

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected RentRecordImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	protected EClass eStaticClass() {
		return LibraryPackage.Literals.RENT_RECORD;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Renter getRenter() {
		if (renter != null && renter.eIsProxy()) {
			InternalEObject oldRenter = (InternalEObject) renter;
			renter = (Renter) eResolveProxy(oldRenter);
			if (renter != oldRenter) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE,
							LibraryPackage.RENT_RECORD__RENTER, oldRenter,
							renter));
			}
		}
		return renter;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Renter basicGetRenter() {
		return renter;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setRenter(Renter newRenter) {
		Renter oldRenter = renter;
		renter = newRenter;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.RENT_RECORD__RENTER, oldRenter, renter));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Book getBook() {
		if (book != null && book.eIsProxy()) {
			InternalEObject oldBook = (InternalEObject) book;
			book = (Book) eResolveProxy(oldBook);
			if (book != oldBook) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE,
							LibraryPackage.RENT_RECORD__BOOK, oldBook, book));
			}
		}
		return book;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Book basicGetBook() {
		return book;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setBook(Book newBook) {
		Book oldBook = book;
		book = newBook;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.RENT_RECORD__BOOK, oldBook, book));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Date getRentDate() {
		return rentDate;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setRentDate(Date newRentDate) {
		Date oldRentDate = rentDate;
		rentDate = newRentDate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.RENT_RECORD__RENT_DATE, oldRentDate,
					rentDate));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Date getExpectedReturnDate() {
		return expectedReturnDate;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setExpectedReturnDate(Date newExpectedReturnDate) {
		Date oldExpectedReturnDate = expectedReturnDate;
		expectedReturnDate = newExpectedReturnDate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE,
					oldExpectedReturnDate, expectedReturnDate));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public Date getReturnDate() {
		return returnDate;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public void setReturnDate(Date newReturnDate) {
		Date oldReturnDate = returnDate;
		returnDate = newReturnDate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					LibraryPackage.RENT_RECORD__RETURN_DATE, oldReturnDate,
					returnDate));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case LibraryPackage.RENT_RECORD__RENTER:
			if (resolve)
				return getRenter();
			return basicGetRenter();
		case LibraryPackage.RENT_RECORD__BOOK:
			if (resolve)
				return getBook();
			return basicGetBook();
		case LibraryPackage.RENT_RECORD__RENT_DATE:
			return getRentDate();
		case LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE:
			return getExpectedReturnDate();
		case LibraryPackage.RENT_RECORD__RETURN_DATE:
			return getReturnDate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case LibraryPackage.RENT_RECORD__RENTER:
			setRenter((Renter) newValue);
			return;
		case LibraryPackage.RENT_RECORD__BOOK:
			setBook((Book) newValue);
			return;
		case LibraryPackage.RENT_RECORD__RENT_DATE:
			setRentDate((Date) newValue);
			return;
		case LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE:
			setExpectedReturnDate((Date) newValue);
			return;
		case LibraryPackage.RENT_RECORD__RETURN_DATE:
			setReturnDate((Date) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public void eUnset(int featureID) {
		switch (featureID) {
		case LibraryPackage.RENT_RECORD__RENTER:
			setRenter((Renter) null);
			return;
		case LibraryPackage.RENT_RECORD__BOOK:
			setBook((Book) null);
			return;
		case LibraryPackage.RENT_RECORD__RENT_DATE:
			setRentDate(RENT_DATE_EDEFAULT);
			return;
		case LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE:
			setExpectedReturnDate(EXPECTED_RETURN_DATE_EDEFAULT);
			return;
		case LibraryPackage.RENT_RECORD__RETURN_DATE:
			setReturnDate(RETURN_DATE_EDEFAULT);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case LibraryPackage.RENT_RECORD__RENTER:
			return renter != null;
		case LibraryPackage.RENT_RECORD__BOOK:
			return book != null;
		case LibraryPackage.RENT_RECORD__RENT_DATE:
			return RENT_DATE_EDEFAULT == null ? rentDate != null
					: !RENT_DATE_EDEFAULT.equals(rentDate);
		case LibraryPackage.RENT_RECORD__EXPECTED_RETURN_DATE:
			return EXPECTED_RETURN_DATE_EDEFAULT == null ? expectedReturnDate != null
					: !EXPECTED_RETURN_DATE_EDEFAULT.equals(expectedReturnDate);
		case LibraryPackage.RENT_RECORD__RETURN_DATE:
			return RETURN_DATE_EDEFAULT == null ? returnDate != null
					: !RETURN_DATE_EDEFAULT.equals(returnDate);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */

	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (rentDate: ");
		result.append(rentDate);
		result.append(", expectedReturnDate: ");
		result.append(expectedReturnDate);
		result.append(", returnDate: ");
		result.append(returnDate);
		result.append(')');
		return result.toString();
	}

} // RentRecordImpl
